package co.unal.visor.util;

import java.awt.Color;
import java.awt.Graphics;
import java.util.ArrayList;

import co.unal.visor.model.Image;
import co.unal.visor.model.interfaces.IFilter;

public class HistoGram implements IFilter {

	@Override
	public Image process(Image img) {
		byte[][] stripArray = img.getStripArray();
		int bitspp = img.getBitspp();
		int width = img.getWidth();
		int height = img.getHeight();
		long[] intArray = new long[256];
		System.out.print("x: " + width + " ;y: " + height + "arreglolength: "
				+ intArray.length);
		for (int x = 0; x < intArray.length; x++) {
			intArray[x] = 0;
		}

		int k = 0;
		int j = 0;
		for (int i = 0; i < stripArray.length; i++) {
			byte[] currentStrip = stripArray[i];
			int tempIndex = 0;
			System.out.println("createPixelMatrix() " + i);
			while (k < height) {
				for (j = 0; j < width; j++) {
					if (tempIndex < stripArray[i].length) {

						// double medRGB = ((currentStrip[tempIndex + 0] *
						// 0.2989
						// + currentStrip[tempIndex + 1] * .5870 +
						// currentStrip[tempIndex + 2] * 0.1140));
						int medRGB = 128+((currentStrip[tempIndex + 0]));
						// System.out.println(medRGB);
						intArray[medRGB] = intArray[medRGB] + 1;

						tempIndex += (bitspp / 8);
					}
				}
				k++;
			}
			stripArray[i] = currentStrip;
		}


		for (int z = 0; z < intArray.length; z++) {
			System.out.println("Numero total en la posicion " + z + ": "
					+ intArray[z]);
			
		}

		return img;
	
	
	
	}
	
	

}
